package agenda;

import java.util.*;

public class Agenda<E extends Entry> {
	
	public Agenda(String ownerName) {
		assert (ownerName != null);
		this.ownerName = ownerName;
	}
	
	public String getOwnerName() {
		return this.ownerName;
	}
	
	private final String ownerName;
	
	public boolean hasAsEntry(Entry entry) {
		return entries.contains(entry);
	}
	
	public synchronized void addEntry(Entry entry) {
		assert (entry != null);
		assert (entry.getAgenda() == this);
		assert (! this.hasAsEntry(entry));
		entries.add(entry);
	}

	public void removeEntry(Entry entry) {
		assert (entry != null);
		assert (entry.getAgenda() == null);
		assert (this.hasAsEntry(entry));
		entries.remove(entry);
	}
	
	private final ArrayList<Entry> entries = new ArrayList<Entry>();
}
